/*
 * Copyright © 2017 eqxiu.com 北京中网易企秀科技有限公司  All rights reserved.
 */

package cn.hermit.nio.client;

import java.nio.channels.SocketChannel;

/**
 * @author JackGao 高建国
 * @description //TODO 设计说明
 * @date 17/5/2017
 */
public class RspHandler {
    private byte[] rsp = null;

    public synchronized boolean handleResponse(SocketChannel socketChannel, byte[] rsp) {
        this.rsp = rsp;
        this.notify();
        return true;
    }

    public synchronized void waitForResponse() {
        while(this.rsp == null) {
            try {
                this.wait();
            } catch (InterruptedException e) {
            }
        }

        System.out.println(new String(this.rsp));
    }
}